﻿using System.Reflection;
using System.Web.Mvc;
using System.Web.Routing;
using Kratos.Framework.Extensions.RouteExtensions;
using Kratos.Framework.Infrastructures;
using Microsoft.Practices.Unity;

namespace Kratos.Modules.Admin
{
    public class AdminModule : IKratosModule, IKratosDataProvider
    {
        private readonly IUnityContainer _container;

        public AdminModule(IUnityContainer container)
        {
            _container = container;
        }

        #region IKratosModule 成员

        public void Initialize()
        {

        }

        public void RegisterRoutes(RouteCollection routes)
        {
            var nameSpace = new[] { "Kratos.Modules.Admin.Controllers" };
            routes.MapLowerCaseRoute("Admin",
                "Admin/{controller}/{action}",
                new { controller = "Home", action = "Index" },
                null,
                nameSpace
                );
        }

        public void RegisterModelBinders(ModelBinderDictionary modelBinders)
        {

        }

        public void RegisterBizServices()
        {

        }

        /// <summary>
        /// 收集整个站点的Action,运行于应用程序初始化时
        /// </summary>
        public void RegisterAction()
        {
            var assembly = Assembly.GetExecutingAssembly();
            SecurityHelper.SetActionByAssembly(assembly);
        }

        public void Unload()
        {

        }

        #endregion

        #region IKratosDataProvider 成员

        public void ConfigDataProvider()
        {

        }

        #endregion
    }
}
